

#include "equipment.h"


int EquipmentAttribute::getTotalAttack(EquipmentAttribute const *resist) const {
	int total = 0;
	if (resist == nullptr) {
		total = slashAttack + bluntAttack + piercingAttack + explosionAttack + fireAttack +
				iceAttack + poisonAttack + thunderAttack + darkAttack + holyAttack;
	} else {
		int n = slashAttack - resist->slashResist;
		if (slashAttack > 0 && n > 0) {
			total += n;
		}
		n = bluntAttack - resist->bluntResist;
		if (bluntAttack > 0 && n > 0) {
			total += n;
		}
		n = piercingAttack - resist->piercingResist;
		if (piercingAttack > 0 && n > 0) {
			total += n;
		}
		n = explosionAttack - resist->explosionResist;
		if (explosionAttack > 0 && n > 0) {
			total += n;
		}
		n = fireAttack - resist->fireResist;
		if (fireAttack > 0 && n > 0) {
			total += n;
		}
		n = iceAttack - resist->iceResist;
		if (iceAttack > 0 && n > 0) {
			total += n;
		}
		n = poisonAttack - resist->poisonResist;
		if (poisonAttack > 0 && n > 0) {
			total += n;
		}
		n = thunderAttack - resist->thunderResist;
		if (thunderAttack > 0 && n > 0) {
			total += n;
		}
		n = darkAttack - resist->darkResist;
		if (darkAttack > 0 && n > 0) {
			total += n;
		}
		n = holyAttack - resist->holyResist;
		if (holyAttack > 0 && n > 0) {
			total += n;
		}
	}
	return total;
}
